﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.Reporting.WebForms;

namespace VisualWebGuiApplication2
{
    public partial class reportinvoices2 : System.Web.UI.Page
    {
        int tankid = 0;
        string size = string.Empty; 
        string Companyname = string.Empty;
        string TankNumber = string.Empty;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                if (null != Request.QueryString["id"])
                {
                    tankid = Convert.ToInt32(Request.QueryString["id"].ToString());                   
                   // renderrep(tankid, string.Empty, string.Empty, string.Empty);
                }
                if (null != Request.QueryString["company"])
                {
                    Companyname = Request.QueryString["company"].ToString();
                    // renderrep(tankid, string.Empty, string.Empty, string.Empty);
                }
                if (null != Request.QueryString["tanknumber"])
                {
                    TankNumber = Request.QueryString["tanknumber"].ToString();
                    // renderrep(tankid, string.Empty, string.Empty, string.Empty);
                }
                if (null != Request.QueryString["size"])
                {
                    size = Request.QueryString["size"].ToString();
                    // renderrep(tankid, string.Empty, string.Empty, string.Empty);
                }
                                   
                    renderrep(tankid, size, Companyname, string.Empty);
                
            }
        }

        public void renderrep(int tankid)
        {
            using (GazOnDevEntities db =new GazOnDevEntities())
            {

                string tankstatus = tankid.ToString();
                var query1 = from i in db.Invoices2
                             select i;
              

               

                //  dd.FirstOrDefault().Datetime = Convert.ToDateTime(dd.FirstOrDefault().Datetime.Value.ToString("MM/dd/yyyy"));
                //dd.FirstOrDefault().Date_of_Fix = Convert.ToDateTime(dd.FirstOrDefault().Date_of_Fix.Value.ToString("MM/dd/yyyy"));

                List<Invoices2> ds2 = query1.ToList<Invoices2>();
              
               
                
              //  int personSigned = Convert.ToInt32(query1.FirstOrDefault().PersonRecipetsignid);
                // int transportCompanyid = Convert.ToInt32(query1.FirstOrDefault().TransportCompanyID);
                 this.reportViewer1.LocalReport.DataSources.Clear();
                // this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dd));
                 this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds2));
            
          
                this.reportViewer1.DataBind();
                reportViewer1.LocalReport.Refresh();
              
                

                
            }

         

        }
       
        public void renderrep(int tankid, string sizea, string companyname,string tanknumber)
        {
            using (GazOnDevEntities db = new GazOnDevEntities())
            {

                string tankstatus = tankid.ToString();
                var query1 = from i in db.Invoices2
                      
                             select i;
             
                List<Invoices2> ds2 = query1.ToList<Invoices2>();
               

                //  int personSigned = Convert.ToInt32(query1.FirstOrDefault().PersonRecipetsignid);
                // int transportCompanyid = Convert.ToInt32(query1.FirstOrDefault().TransportCompanyID);
                this.reportViewer1.LocalReport.DataSources.Clear();
                // this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", dd));
                this.reportViewer1.LocalReport.DataSources.Add(new ReportDataSource("DataSet1", ds2));
               
                this.reportViewer1.DataBind();
                reportViewer1.LocalReport.Refresh();
               



            }

          



        }
    }
}